// models/treasureBox.js
import url1 from "@/assets/p1/rope.png";
import url2 from "@/assets/p1/magnifier.png";
import url3 from "@/assets/p1/calculator.png";
import url4 from "@/assets/p1/balance.png";

export default {
	namespace: "treasureBox",
	state: {
		items: [
			{ id: 1, name: "长长的绳子", imageURL: url1, is_displayed: true },
			{
				id: 2,
				name: "放大镜",
				imageURL: url2,
				is_displayed: true,
			},
			{
				id: 3,
				name: "算筹",
				imageURL: url3,
				is_displayed: false,
			},
			{
				id: 4,
				name: "天平",
				imageURL: url4,
				is_displayed: false,
			},
		],
	},
	reducers: {
		showItem(state, action) {
			return {
				...state,
				items: state.items.map(item =>
					item.id === action.payload
						? { ...item, is_displayed: true }
						: item
				),
			};
		},
	},
};
